/**
 * BBD Service Inc
 * All Rights Reserved @2018
 */
package com.xiaoke.web.controller;

import com.xiaoke.web.service.DictionaryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * 首页设置管理
 *
 * @author
 */
@Controller
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private DictionaryService dictionaryService;

    @RequestMapping(value = "/list")
    public String list(Model model) {
        return "category/list";
    }


    @RequestMapping(value = "/input")
    public String input(Model model, Integer id) {
        String isEdit;
        if (id != null && id != 0) {
            isEdit="edit";
            //IndexCategory category = indexCategoryService.selectByPrimaryKey(id);
            //model.addAttribute("entity", category);
        } else {
            isEdit="add";
            //model.addAttribute("entity", new IndexCategory());
        }
        model.addAttribute("isEdit",isEdit);
        return "category/input";
    }

//    @RequestMapping(value = "/save")
//    public String save(IndexCategory indexCategory) {
//        if (indexCategory.getId() == null || indexCategory.getId() == 0) {
//            indexCategoryService.insert(indexCategory);
//        } else {
//            indexCategoryService.updateByPrimaryKey(indexCategory);
//        }
//        return "redirect:/category/list";
//    }

//
//    @RequestMapping(value = "/delete")
//    @ResponseBody
//    public AjaxMsg delete(Integer indexCategoryId) {
//        Map map = new HashMap();
//        AjaxMsg ajaxMsg =new AjaxMsg();
//        map.put("indexCategoryId", indexCategoryId);
//        List list = indexMovieService.selectByParams(map);
//        if (!ValidUtil.isEmpty(list)) {
//            ajaxMsg.setCode(AjaxMsg.FAILURE);
//            ajaxMsg.setMessage("该分类中存在电影，不可删除");
//            return ajaxMsg;
//        }else{
//            indexCategoryService.deleteByPrimaryKey(indexCategoryId);
//        }
//        return new AjaxMsg();
//    }

}
